import { ShapeFlag } from '../flags'
import type { vnode } from "../../types"


const helper = {
  _c(tag:string, props:object, ...children:unknown[]) {
   return {
    tag,
    props,
    children: Array.isArray(children[0]) ? [] : children
   }
  },
  _v(text:string) {
    return text
  },
  _s(expr:string) {
    return expr
  },
}

export function render(fn:Function, data:object) {
  const thisArg = Object.assign(helper, data)
  const vnode = fn.call(thisArg)

  return vnode
}


export function createVNode():vnode {
  return {
    tag:'div',
    props:{},
    children:[],
    shapeFlag: ShapeFlag.ELEMENT|ShapeFlag.ARRAY_CHILDREN
  }
}

export function mount() {}

export function unmounted() {}
